﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

    /// <summary>
    /// 判断用户是否已经登录-登录窗口]
    /// </summary>
    public class IsLoginBoxAttribute : AuthorizeAttribute
    {
        /// <summary>
        /// 判断用户是否已经登录
        /// </summary>
        /// <param name="httpContext"></param>
        /// <returns>登录窗口</returns>
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var userinfo = LoginModel.User;
            if (userinfo == null || userinfo.Uid == 0)
            {
                httpContext.Response.ContentType = "html";
                httpContext.Response.Redirect("/login/OpenBoxLogin");
                return false;
            }
            return true;
        }
    }
